#ifndef _MODEL_H
#define _MODEL_H

/*******************************\
 * netbook database table model.
\*******************************/
typedef struct _User {
   uint32_t id;
   char	*nickname;
   char *mail;
   char *passwd;
   char *time_reg;
   char *time_lastlogin;
   char *time_lastupdate;
   uint8_t attribute;
}User;

#define USER_ID			(1<<0)
#define USER_NICKNAME		(1<<1)
#define USER_MAIL		(1<<2)
#define USER_PASSWD		(1<<3)
#define USER_TIME_REG		(1<<4)
#define USER_TIME_LASTLOGIN	(1<<4)
#define USER_TIME_LASTUPDATE	(1<<4)
#define USER_ATTRIBUTE		(1<<5)

typedef struct _Note {
    uint64_t id;
    uint32_t owner_id;
    char *uuid;
    char *title;
    char *content;
    char *time_create;
    char *time_lastupdate;
    uint8_t version;
    uint32_t attribute;
}Note;

// struct fields.
#define NOTE_ID			(1<<0)
#define NOTE_OWNER_ID		(1<<1)
#define NOTE_UUID		(1<<2)
#define NOTE_TITLE		(1<<3)
#define NOTE_CONTENT		(1<<4)
#define NOTE_TIME_CREATE	(1<<5)
#define NOTE_TIME_LASTUPDATE	(1<<6)
#define NOTE_VERSION		(1<<7)
#define NOTE_ATTRIBUTE		(1<<8)

// attribute 1-meaning.
#define NOTE_ATTR_PUBLIC    (1<<0)

typedef struct _Favorite {
    uint32_t user_id;
    uint64_t note_id;
    char *time_create;
    char *time_change;
    uint8_t status;
}Favorite;

#define FAVORITE_USER_ID	(1<<0)
#define FAVORITE_NOTE_ID	(1<<1)
#define FAVORITE_TIME_CREATE	(1<<2)
#define FAVORITE_TIME_CHANGE	(1<<3)
#define FAVORITE_STATUS		(1<<4)

typedef struct _Tag {
    char *name;
    uint64_t note_id;
    uint32_t owner_id;
    char *time_create;
    uint64_t count_ref;
}Tag;

#define TAG_NAME	(1<<0)
#define TAG_NOTE_ID	(1<<1)
#define TAG_OWNER_ID	(1<<2)
#define TAG_TIME_CREATE	(1<<3)
#define TAG_COUNT_REF	(1<<4)

typedef struct _Share {
    uint64_t note_id;
    uint32_t user_id;
    char *user_mail;
    uint32_t owner_id;
    char *time_create;
    char *time_lastupdate;
    uint32_t attribute;
}Share;
#define SHARE_NOTE_ID		(1<<0)
#define SHARE_USER_ID		(1<<1)
#define SHARE_USER_MAIL		(1<<1)
#define SHARE_OWNER_ID		(1<<2)
#define SHARE_TIME_CREATE	(1<<2)
#define SHARE_TIME_LASTUPDATE	(1<<2)
#define SHARE_ATTRIBUTE		(1<<3)

typedef struct _Session {
    char *uuid;
    uint32_t user_id;
    char *time_create;
    uint8_t attribute;
}Session;

#define SESSION_UUID	    (1<<0)
#define SESSION_USER_ID	    (1<<1)
#define SESSION_LAST_TIME   (1<<2)
#define SESSION_ATTRIBUTE   (1<<2)


// transfer this.
typedef struct _ArrayTable {
    int size;
    void *ptr;
}ArrayTable;

// attribute
// Note
#define PUBLIC	(1<<0)

#endif /* _MODEL_H */
